<template>
  <div class="anomaly-table-panel">
    
    
    <div class="panel-header">
      <h3>{{ title }}</h3>
      <div class="table-controls">
        <span v-if="isDisconnected" class="disconnected-indicator">数据断线</span>
        <el-button size="small" circle text @click="advancedFilterDialogVisible = true" :title="'高级筛选'">
          <el-icon><Filter /></el-icon>
        </el-button>
      </div>
    </div>
    <div class="panel-content">
      <el-table
        :data="anomalyData"
        style="width: 100%"
        size="small"
        :header-cell-style="{ background: 'rgba(24, 150, 146, 0.4)', color: '#ffffff' }"
        :cell-style="{ background: 'transparent', color: '#ffffff' }"
        :row-style="{ background: 'transparent' }"
        height="460"
        @row-click="handleRowClick"
      >
        <!-- <el-table-column type="index" label="序号" align="center" /> -->
        <el-table-column prop="xCoordinate" label="点位" align="center" width="155" >
          <template #default="{ row }">
            <span>
              {{ row.xCoordinate }},{{ row.yCoordinate }}
            </span>
          </template>
        </el-table-column>
                <el-table-column prop="windSpeed" label="风速" />

        <el-table-column prop="windDirection" label="风向">
          <template #default="{ row }">
            <span :class="getWindDirectionClass(row.windDirection)">
              {{classifyWindDirections(row.windDirection) }}
            </span>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <!-- 高级筛选弹窗 -->
    <el-dialog 
      v-model="advancedFilterDialogVisible" 
      title="高级筛选" 
      width="420px"
      :append-to-body="true"
      :modal="true"
      :center="true"
      :close-on-click-modal="false"
      :close-on-press-escape="true"
      :destroy-on-close="false"
      class="advanced-filter-dialog"
    >
      <el-form :model="queryParams" label-width="90px">
        <el-form-item label="时间" prop="timeParam">
          <TimeSelector
            v-model="queryParams.timeParam"
            :show-pagination="true"
            :default-page-size="20"
            placeholder="请选择时间"
            width="260px"
            :city="queryParams.city"
            @change="handleTimeChange"
            @load-complete="handleTimeLoadComplete"
            ref="timeSelectorRef"
          />
        </el-form-item>
        <el-form-item label="X坐标范围" prop="xCoordinateRange">
          <div style="display: flex; align-items: center; gap: 8px; width: 260px;">
            <div style="display: flex; align-items: center;">
              <span style="color: #909399; margin-right: 4px; font-size: 14px;">{{ xCoordinateBase }}.</span>
              <el-input
                v-model="xCoordinateMinDecimal" 
                placeholder="最小值" 
                style="width: 100px" 
                maxlength="6"
                @input="handleXMinInput"
                @blur="handleXMinBlur"
              />
            </div>
            <span style="color: #909399;">至</span>
            <div style="display: flex; align-items: center;">
              <span style="color: #909399; margin-right: 4px; font-size: 14px;">{{ xCoordinateBase }}.</span>
              <el-input
                v-model="xCoordinateMaxDecimal" 
                placeholder="最大值" 
                style="width: 100px" 
                maxlength="6"
                @input="handleXMaxInput"
                @blur="handleXMaxBlur"
              />
            </div>
          </div>
        </el-form-item>
        <el-form-item label="Y坐标范围" prop="yCoordinateRange">
          <div style="display: flex; align-items: center; gap: 8px; width: 260px;">
            <div style="display: flex; align-items: center;">
              <span style="color: #909399; margin-right: 4px; font-size: 14px;">{{ yCoordinateBase }}.</span>
              <el-input
                v-model="yCoordinateMinDecimal" 
                placeholder="最小值" 
                style="width: 100px" 
                maxlength="6"
                @input="handleYMinInput"
                @blur="handleYMinBlur"
              />
            </div>
            <span style="color: #909399;">至</span>
            <div style="display: flex; align-items: center;">
              <span style="color: #909399; margin-right: 4px; font-size: 14px;">{{ yCoordinateBase }}.</span>
              <el-input
                v-model="yCoordinateMaxDecimal" 
                placeholder="最大值" 
                style="width: 100px" 
                maxlength="6"
                @input="handleYMaxInput"
                @blur="handleYMaxBlur"
              />
            </div>
          </div>
        </el-form-item>
        <el-form-item label="最大风速" prop="windSpeedLike">
          <div style="display: flex; align-items: center; width: 260px;">
            <el-input-number v-model="queryParams.windSpeedLike" :precision="2" :controls="false" placeholder="请输入风速" style="flex: 1;" />
            <span style="margin-left: 8px; color: #000; font-size: 14px;">m/s</span>
          </div>
        </el-form-item>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
          <el-button @click="advancedFilterDialogVisible = false">取消</el-button>
          <el-button @click="resetAdvancedFilters">重置</el-button>
          <el-button type="primary" @click="applyAdvancedFilters">确定</el-button>
        </div>
      </template>
    </el-dialog>
  </div>
</template>

<script setup>
import { ref, reactive, onMounted, onBeforeUnmount, watch } from 'vue'
import { Refresh, Filter } from '@element-plus/icons-vue'
import {
  tableQuery,
  windDataPPI,
  getConfig,
  alarmRecord
} from '@/api/system/user'
import TimeSelector from '@/components/TimeSelector/index.vue'
import dayjs from 'dayjs'
const props = defineProps({
  title: {
    type: String,
    default: '设备异常记录'
  },
  deviceType: {
    type: String,
    default: 'A' // A 或 B
  }
})
const configForm = reactive({
  id: 0,
  max: null,
  min: null
})
const advancedFilterDialogVisible = ref(false)
// 时间选项数据
const timeOptions = ref([])
// 查询参数
const queryParams = reactive({
  city: "hefei",
  pageNum: 3,
  pageSize: 1,
  type: 'PPI',
  timeParam: undefined,
  ipaddr: undefined,
  userName: undefined,
  status: undefined,
  max: undefined,
  min: undefined,
  // X坐标范围
  xCoordinateMin: undefined,
  xCoordinateMax: undefined,
  // Y坐标范围
  yCoordinateMin: undefined,
  yCoordinateMax: undefined,
  windSpeedLike: undefined,
})
const anomalyData = ref([])
// 断线状态
const isDisconnected = ref(false)
// 时间选择器引用
const timeSelectorRef = ref()

// X坐标和Y坐标的整数部分（基础值，根据雷达站动态设置）
const xCoordinateBase = ref(117) // 默认合肥站
const yCoordinateBase = ref(32) // 默认合肥站

// X坐标和Y坐标的小数部分（用于输入，字符串类型以保留输入）
const xCoordinateMinDecimal = ref('')
const xCoordinateMaxDecimal = ref('')
const yCoordinateMinDecimal = ref('')
const yCoordinateMaxDecimal = ref('')

// 标志：是否正在由用户输入更新（避免 watch 循环更新）
const isUserInputting = ref({
  xMin: false,
  xMax: false,
  yMin: false,
  yMax: false
})

// 只允许输入数字
const onlyNumbers = (value) => {
  return value.replace(/[^\d]/g, '')
}

// 处理X坐标最小值输入
const handleXMinInput = (value) => {
  isUserInputting.value.xMin = true
  xCoordinateMinDecimal.value = onlyNumbers(value)
  updateXMinCoordinate()
  // 延迟重置标志，避免 watch 干扰
  setTimeout(() => {
    isUserInputting.value.xMin = false
  }, 100)
}

// 处理X坐标最小值失焦
const handleXMinBlur = () => {
  isUserInputting.value.xMin = false
  updateXMinCoordinate()
}

// 更新X坐标最小值到完整坐标
const updateXMinCoordinate = () => {
  if (xCoordinateMinDecimal.value && xCoordinateMinDecimal.value.length > 0) {
    const decimalValue = parseInt(xCoordinateMinDecimal.value.padEnd(6, '0')) / Math.pow(10, 6)
    queryParams.xCoordinateMin = xCoordinateBase.value + decimalValue
  } else {
    queryParams.xCoordinateMin = undefined
  }
}

// 处理X坐标最大值输入
const handleXMaxInput = (value) => {
  isUserInputting.value.xMax = true
  xCoordinateMaxDecimal.value = onlyNumbers(value)
  updateXMaxCoordinate()
  // 延迟重置标志，避免 watch 干扰
  setTimeout(() => {
    isUserInputting.value.xMax = false
  }, 100)
}

// 处理X坐标最大值失焦
const handleXMaxBlur = () => {
  isUserInputting.value.xMax = false
  updateXMaxCoordinate()
}

// 更新X坐标最大值到完整坐标
const updateXMaxCoordinate = () => {
  if (xCoordinateMaxDecimal.value && xCoordinateMaxDecimal.value.length > 0) {
    const decimalValue = parseInt(xCoordinateMaxDecimal.value.padEnd(6, '0')) / Math.pow(10, 6)
    queryParams.xCoordinateMax = xCoordinateBase.value + decimalValue
  } else {
    queryParams.xCoordinateMax = undefined
  }
}

// 处理Y坐标最小值输入
const handleYMinInput = (value) => {
  isUserInputting.value.yMin = true
  yCoordinateMinDecimal.value = onlyNumbers(value)
  updateYMinCoordinate()
  // 延迟重置标志，避免 watch 干扰
  setTimeout(() => {
    isUserInputting.value.yMin = false
  }, 100)
}

// 处理Y坐标最小值失焦
const handleYMinBlur = () => {
  isUserInputting.value.yMin = false
  updateYMinCoordinate()
}

// 更新Y坐标最小值到完整坐标
const updateYMinCoordinate = () => {
  if (yCoordinateMinDecimal.value && yCoordinateMinDecimal.value.length > 0) {
    const decimalValue = parseInt(yCoordinateMinDecimal.value.padEnd(6, '0')) / Math.pow(10, 6)
    queryParams.yCoordinateMin = yCoordinateBase.value + decimalValue
  } else {
    queryParams.yCoordinateMin = undefined
  }
}

// 处理Y坐标最大值输入
const handleYMaxInput = (value) => {
  isUserInputting.value.yMax = true
  yCoordinateMaxDecimal.value = onlyNumbers(value)
  updateYMaxCoordinate()
  // 延迟重置标志，避免 watch 干扰
  setTimeout(() => {
    isUserInputting.value.yMax = false
  }, 100)
}

// 处理Y坐标最大值失焦
const handleYMaxBlur = () => {
  isUserInputting.value.yMax = false
  updateYMaxCoordinate()
}

// 更新Y坐标最大值到完整坐标
const updateYMaxCoordinate = () => {
  if (yCoordinateMaxDecimal.value && yCoordinateMaxDecimal.value.length > 0) {
    const decimalValue = parseInt(yCoordinateMaxDecimal.value.padEnd(6, '0')) / Math.pow(10, 6)
    queryParams.yCoordinateMax = yCoordinateBase.value + decimalValue
  } else {
    queryParams.yCoordinateMax = undefined
  }
}

// 监听完整坐标值变化，同步更新小数部分显示值（字符串格式，仅在非用户输入时更新）
watch(() => queryParams.xCoordinateMin, (val) => {
  // 如果正在用户输入，跳过 watch 更新，避免覆盖用户输入的前导零
  if (isUserInputting.value.xMin) {
    return
  }
  if (val !== null && val !== undefined && val >= xCoordinateBase.value) {
    const decimalPart = Math.round((val - xCoordinateBase.value) * Math.pow(10, 6))
    xCoordinateMinDecimal.value = String(decimalPart)
  } else {
    xCoordinateMinDecimal.value = ''
  }
}, { immediate: true })

watch(() => queryParams.xCoordinateMax, (val) => {
  // 如果正在用户输入，跳过 watch 更新，避免覆盖用户输入的前导零
  if (isUserInputting.value.xMax) {
    return
  }
  if (val !== null && val !== undefined && val >= xCoordinateBase.value) {
    const decimalPart = Math.round((val - xCoordinateBase.value) * Math.pow(10, 6))
    xCoordinateMaxDecimal.value = String(decimalPart)
  } else {
    xCoordinateMaxDecimal.value = ''
  }
}, { immediate: true })

watch(() => queryParams.yCoordinateMin, (val) => {
  // 如果正在用户输入，跳过 watch 更新，避免覆盖用户输入的前导零
  if (isUserInputting.value.yMin) {
    return
  }
  if (val !== null && val !== undefined && val >= yCoordinateBase.value) {
    const decimalPart = Math.round((val - yCoordinateBase.value) * Math.pow(10, 6))
    yCoordinateMinDecimal.value = String(decimalPart)
  } else {
    yCoordinateMinDecimal.value = ''
  }
}, { immediate: true })

watch(() => queryParams.yCoordinateMax, (val) => {
  // 如果正在用户输入，跳过 watch 更新，避免覆盖用户输入的前导零
  if (isUserInputting.value.yMax) {
    return
  }
  if (val !== null && val !== undefined && val >= yCoordinateBase.value) {
    const decimalPart = Math.round((val - yCoordinateBase.value) * Math.pow(10, 6))
    yCoordinateMaxDecimal.value = String(decimalPart)
  } else {
    yCoordinateMaxDecimal.value = ''
  }
}, { immediate: true })

// 定义emit事件
const emit = defineEmits(['row-click'])

// 处理行点击事件
const handleRowClick = (row) => {
  console.log('报警记录行点击:', row)
  // 向父组件发送行点击事件
  emit('row-click', row)
}

// 处理时间选择变化
const handleTimeChange = (value) => {
  console.log('时间选择变化:', value)
  // 可以在这里添加额外的处理逻辑
}

// 处理时间数据加载完成
const handleTimeLoadComplete = (timeOptions) => {
  console.log('时间数据加载完成，共', timeOptions.length, '个选项')
  // 可以在这里添加额外的处理逻辑
}

// 格式化时间显示
const formatDateTime = (dateTimeString) => {
  if (!dateTimeString) {
    return '--'
  }
  
  try {
    return dayjs(dateTimeString).format('YYYY-MM-DD HH:mm:ss')
  } catch (error) {
    console.error('时间格式化错误:', error)
    return dateTimeString
  }
}

function classifyWindDirections(directions) {
  if (directions === null || directions === undefined || directions === '') {
    return '未知'
  }
  
  const angle = parseFloat(directions)
  if (isNaN(angle)) {
    return '未知'
  }
  
  // 将角度标准化到0-360度范围
  const normalizedAngle = ((angle % 360) + 360) % 360
  
  // 8个主要方向，每个方向45度
  if (normalizedAngle >= 337.5 || normalizedAngle < 22.5) {
    return '北'
  } else if (normalizedAngle >= 22.5 && normalizedAngle < 67.5) {
    return '东北'
  } else if (normalizedAngle >= 67.5 && normalizedAngle < 112.5) {
    return '东'
  } else if (normalizedAngle >= 112.5 && normalizedAngle < 157.5) {
    return '东南'
  } else if (normalizedAngle >= 157.5 && normalizedAngle < 202.5) {
    return '南'
  } else if (normalizedAngle >= 202.5 && normalizedAngle < 247.5) {
    return '西南'
  } else if (normalizedAngle >= 247.5 && normalizedAngle < 292.5) {
    return '西'
  } else if (normalizedAngle >= 292.5 && normalizedAngle < 337.5) {
    return '西北'
  }
  
  return '未知'
}

// 获取风向样式类
function getWindDirectionClass(directions) {
  if (directions === null || directions === undefined || directions === '') {
    return 'wind-unknown'
  }
  
  const angle = parseFloat(directions)
  if (isNaN(angle)) {
    return 'wind-unknown'
  }
  
  // 将角度标准化到0-360度范围
  const normalizedAngle = ((angle % 360) + 360) % 360
  
  // 8个主要方向，每个方向45度
  if (normalizedAngle >= 337.5 || normalizedAngle < 22.5) {
    return 'wind-north'
  } else if (normalizedAngle >= 22.5 && normalizedAngle < 67.5) {
    return 'wind-northeast'
  } else if (normalizedAngle >= 67.5 && normalizedAngle < 112.5) {
    return 'wind-east'
  } else if (normalizedAngle >= 112.5 && normalizedAngle < 157.5) {
    return 'wind-southeast'
  } else if (normalizedAngle >= 157.5 && normalizedAngle < 202.5) {
    return 'wind-south'
  } else if (normalizedAngle >= 202.5 && normalizedAngle < 247.5) {
    return 'wind-southwest'
  } else if (normalizedAngle >= 247.5 && normalizedAngle < 292.5) {
    return 'wind-west'
  } else if (normalizedAngle >= 292.5 && normalizedAngle < 337.5) {
    return 'wind-northwest'
  }
  
  return 'wind-unknown'
}

// 获取异常类型样式类
const getAnomalyClass = (content) => {
  const criticalAnomalies = ['通讯中断', '连接丢失', '系统故障', '硬件故障', '系统重启']
  const warningAnomalies = ['电压过高', '温度异常', '温度过高', '振动超标', '位置偏移']
  
  if (criticalAnomalies.includes(content)) {
    return 'anomaly-critical'
  } else if (warningAnomalies.includes(content)) {
    return 'anomaly-warning'
  } else {
    return 'anomaly-normal'
  }
}

async function getDataConfig() { 
  const response = await getConfig()
    if (response.code === 200) {
      // 填充配置表单数据
      Object.assign(configForm, response.data)
      refreshData()
    } else {
      proxy.$modal.msgError(response.msg || '获取配置失败')
    }
}
/** 获取时间选项数据 */
async function getTimeOptions() {
  const response = await tableQuery(queryParams)
    if (response.code === 200) {
      timeOptions.value = response.data.result || []
      // 如果有数据且当前没有选择时间，自动选择第一个
      if (timeOptions.value.length > 0 && !queryParams.timeParam) {
        queryParams.timeParam = timeOptions.value[0].dateTimeString
        // 自动选择第一个时间后，获取对应的数据
        await getDataConfig()
      }
    }
   
}
// 刷新数据
const refreshData = async () => {
  if (!queryParams.type || !queryParams.timeParam) {
    console.warn('请选择模式和时间')
    return
  }
  try {
    const raw = {
      timeParam: queryParams.timeParam,
      pageNum: queryParams.pageNum,
      pageSize: 10000,
      max: configForm.max,
      min: configForm.min,
      // X坐标范围参数
      xCoordinateMin: queryParams.xCoordinateMin,
      xCoordinateMax: queryParams.xCoordinateMax,
      // Y坐标范围参数
      yCoordinateMin: queryParams.yCoordinateMin,
      yCoordinateMax: queryParams.yCoordinateMax,
      windSpeedLike: queryParams.windSpeedLike,
    }
    const params = Object.fromEntries(Object.entries(raw).filter(([_, v]) => v !== undefined && v !== null && v !== ''))
    let response = await alarmRecord(params)
    anomalyData.value = response.data.result
  } catch (error) {
    proxy.$modal.msgError('获取数据失败')
  }

  
}

function applyAdvancedFilters(){
  advancedFilterDialogVisible.value = false
  refreshData()
}
function resetAdvancedFilters(){
  // 重置坐标范围参数
  queryParams.xCoordinateMin = undefined
  queryParams.xCoordinateMax = undefined
  queryParams.yCoordinateMin = undefined
  queryParams.yCoordinateMax = undefined
  queryParams.windSpeedLike = undefined
  queryParams.timeParam = undefined
  // 重置小数部分输入值
  xCoordinateMinDecimal.value = ''
  xCoordinateMaxDecimal.value = ''
  yCoordinateMinDecimal.value = ''
  yCoordinateMaxDecimal.value = ''
  // 重置时间选择器
  if (timeSelectorRef.value) {
    timeSelectorRef.value.clearTimeFilter()
  }
}


// 监听连接状态变化
const handleConnectionStatusChange = (event) => {
  isDisconnected.value = event.detail.isDisconnected
}

// 监听雷达选择变更事件
const handleRadarSelected = async (event) => {
  try {
    const { city } = event.detail || {}
    // 更新城市参数（合肥站 -> hefei, 宣城站 -> xuancheng）
    if (city && (city === 'hefei' || city === 'xuancheng')) {
      const oldCity = queryParams.city
      queryParams.city = city
      console.log('AlarmTable: 雷达选择变更，城市参数已更新为:', city)
      
      // 根据雷达站更新坐标基础值
      if (city === 'hefei') {
        // 合肥站：X坐标范围固定为117，Y坐标范围固定为32
        xCoordinateBase.value = 117
        yCoordinateBase.value = 32
      } else if (city === 'xuancheng') {
        // 宣城站：X坐标范围固定为119，Y坐标范围固定为30
        xCoordinateBase.value = 119
        yCoordinateBase.value = 30
      }
      
      // 如果城市参数发生变化，重新获取时间选项
      if (oldCity !== city) {
        queryParams.timeParam = undefined // 清除时间选择
        // 重置坐标范围参数（因为基础值已改变）
        queryParams.xCoordinateMin = undefined
        queryParams.xCoordinateMax = undefined
        queryParams.yCoordinateMin = undefined
        queryParams.yCoordinateMax = undefined
        // 重置小数部分输入值
        xCoordinateMinDecimal.value = ''
        xCoordinateMaxDecimal.value = ''
        yCoordinateMinDecimal.value = ''
        yCoordinateMaxDecimal.value = ''
        // 重置时间选择器
        if (timeSelectorRef.value) {
          timeSelectorRef.value.clearTimeFilter()
        }
        // 重新获取时间选项
        await getTimeOptions()
      }
    }
  } catch (error) {
    console.error('AlarmTable: 处理雷达选择变更失败:', error)
  }
}

onMounted(async () => {
  // 根据当前城市设置基础坐标值
  if (queryParams.city === 'hefei') {
    xCoordinateBase.value = 117
    yCoordinateBase.value = 32
  } else if (queryParams.city === 'xuancheng') {
    xCoordinateBase.value = 119
    yCoordinateBase.value = 30
  }
  
  await getTimeOptions()
  // 添加事件监听器
  window.addEventListener('connectionStatusChanged', handleConnectionStatusChange)
  window.addEventListener('radar-selected', handleRadarSelected)
})

onBeforeUnmount(() => {
  // 移除事件监听器
  window.removeEventListener('connectionStatusChanged', handleConnectionStatusChange)
  window.removeEventListener('radar-selected', handleRadarSelected)
})
</script>

<style scoped lang="scss">
.anomaly-table-panel {
  background: transparent;
  border: none;
  border-radius: 8px;
  padding: 8px;
  color: #ffffff;
  min-width: 20px;
  box-shadow: none;
  position: relative;
  .Select{ display:none; }
  .filters{
    position: absolute;
    z-index: 1001;
    right: 12px;
    top: 52px;
    display: flex;
    align-items: center;
    gap: 6px;
    .flt{ width: 140px; }
  }
  .panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    padding: 9px 16px;
    background: linear-gradient(135deg, rgba(24, 150, 146, 0.8) 0%, rgba(24, 150, 146, 0.6) 100%);
    border: 1px solid rgba(24, 150, 146, 0.4);
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(24, 150, 146, 0.2);
    position: relative;
    overflow: hidden;
    min-height: 40px;
    backdrop-filter: blur(8px);
    
    &::before {
      content: '';
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background: linear-gradient(135deg, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0.05) 100%);
      pointer-events: none;
    }
    
    h3 {
      margin: 0;
      color: #ffffff;
      font-size: 14px;
      font-weight: 700;
      font-family: 'Microsoft YaHei', 'PingFang SC', 'Helvetica Neue', Arial, sans-serif;
      text-shadow: 0 2px 4px rgba(0,0,0,0.3);
      letter-spacing: 1px;
      position: relative;
      z-index: 1;
      display: flex;
      align-items: center;
      gap: 8px;
      
      &::before {
        content: '🚨';
        font-size: 16px;
        filter: drop-shadow(0 1px 2px rgba(0,0,0,0.2));
        animation: iconPulse 2s ease-in-out infinite;
      }
      
      &::after {
        content: '';
        position: absolute;
        left: -8px;
        top: 50%;
        transform: translateY(-50%);
        width: 3px;
        height: 20px;
        background: linear-gradient(180deg, #ffffff 0%, rgba(255,255,255,0.3) 100%);
        border-radius: 2px;
        box-shadow: 0 0 8px rgba(255,255,255,0.5);
      }
    }
    
    .table-controls {
      display: flex;
      align-items: center;
      gap: 8px;
      
      .disconnected-indicator {
        color: #ff4444;
        font-weight: bold;
        font-size: 12px;
        padding: 2px 8px;
        background: rgba(255, 68, 68, 0.2);
        border: 1px solid rgba(255, 68, 68, 0.4);
        border-radius: 4px;
        animation: blink 1s infinite;
      }
      
      .el-button {
        background: rgba(24, 150, 146, 0.3);
        border: 2px solid rgba(255, 255, 255, 0.6);
        color: #ffffff;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
        
        &:hover {
          background: rgba(24, 150, 146, 0.5);
          border-color: rgba(255, 255, 255, 0.8);
          color: #ffffff;
          box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
          transform: translateY(-1px);
        }
        
        // 图标样式优化
        .el-icon {
          color: #ffffff !important;
          font-size: 16px;
          font-weight: bold;
          filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.5));
          text-shadow: 0 0 4px rgba(255, 255, 255, 0.3);
        }
        
        &:hover .el-icon {
          color: #ffffff !important;
          filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.6));
          transform: scale(1.15);
          transition: all 0.2s ease;
        }
      }
    }
  }
  
  .panel-content {
    :deep(.el-table) {
      background: transparent;
      
      .el-table__header-wrapper {
        background: rgba(24, 150, 146, 0.4);
        border-radius: 6px 6px 0 0;
      }
      
      .el-table__body-wrapper {
        background: transparent;
      }
      
      .el-table__row {
        background: transparent;
        height: 32px;
        
        &:hover {
          background: rgba(24, 150, 146, 0.1) !important;
        }
      }
      
      .el-table__cell {
        border-color: rgba(24, 150, 146, 0.2);
        padding: 4px 8px;
      }
      
      .el-table__header {
        th {
          background: rgba(24, 150, 146, 0.4);
          color: #ffffff;
          font-weight: 600;
          height: 32px;
          padding: 4px 8px;
          border-color: rgba(24, 150, 146, 0.5);
        }
      }
      
      .el-table__body {
        td {
          color: #ffffff;
          border-color: rgba(24, 150, 146, 0.2);
        }
      }
    }
  }
}

.anomaly-critical {
  color: #ef4444;
  font-weight: bold;
  background: #fef2f2;
  padding: 2px 6px;
  border-radius: 4px;
}

.anomaly-warning {
  color: #f59e0b;
  font-weight: bold;
  background: #fffbeb;
  padding: 2px 6px;
  border-radius: 4px;
}

.anomaly-normal {
  color: #10b981;
  font-weight: bold;
  background: #f0fdf4;
  padding: 2px 6px;
  border-radius: 4px;
}

/* 风向样式 - 适配绿色背景 */
.wind-north {
  color: #ffffff;
  font-weight: bold;
  background: rgba(30, 64, 175, 0.8);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(30, 64, 175, 0.6);
}

.wind-northeast {
  color: #ffffff;
  font-weight: bold;
  background: rgba(124, 58, 237, 0.8);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(124, 58, 237, 0.6);
}

.wind-east {
  color: #ffffff;
  font-weight: bold;
  background: rgba(5, 150, 105, 0.8);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(5, 150, 105, 0.6);
}

.wind-southeast {
  color: #ffffff;
  font-weight: bold;
  background: rgba(220, 38, 38, 0.8);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(220, 38, 38, 0.6);
}

.wind-south {
  color: #ffffff;
  font-weight: bold;
  background: rgba(234, 88, 12, 0.8);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(234, 88, 12, 0.6);
}

.wind-southwest {
  color: #ffffff;
  font-weight: bold;
  background: rgba(202, 138, 4, 0.8);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(202, 138, 4, 0.6);
}

.wind-west {
  color: #ffffff;
  font-weight: bold;
  background: rgba(8, 145, 178, 0.8);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(8, 145, 178, 0.6);
}

.wind-northwest {
  color: #ffffff;
  font-weight: bold;
  background: rgba(190, 24, 93, 0.8);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(190, 24, 93, 0.6);
}

.wind-unknown {
  color: #ffffff;
  font-weight: bold;
  background: rgba(107, 114, 128, 0.8);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(107, 114, 128, 0.6);
}

// 图标动画
@keyframes iconPulse {
  0%, 100% {
    transform: scale(1);
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.2)) brightness(1);
  }
  50% {
    transform: scale(1.1);
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3)) brightness(1.2);
  }
}

// 断线指示器闪烁动画
@keyframes blink {
  0%, 50% {
    opacity: 1;
  }
  51%, 100% {
    opacity: 0.3;
  }
}

// 高级筛选弹窗样式
:deep(.advanced-filter-dialog) {
  .el-dialog {
    background: linear-gradient(135deg, rgba(24, 150, 146, 0.15) 0%, rgba(24, 150, 146, 0.1) 100%);
    border: 1px solid rgba(24, 150, 146, 0.3);
    border-radius: 12px;
    box-shadow: 
      0 6px 15px rgba(24, 150, 146, 0.2),
      0 2px 4px rgba(24, 150, 146, 0.1),
      inset 0 1px 0 rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(8px);
  }
  
  .el-dialog__header {
    background: linear-gradient(135deg, rgba(24, 150, 146, 0.8) 0%, rgba(24, 150, 146, 0.6) 100%);
    border-radius: 12px 12px 0 0;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(24, 150, 146, 0.4);
    
    .el-dialog__title {
      color: #ffffff;
      font-weight: 600;
      font-size: 16px;
    }
    
    .el-dialog__headerbtn {
      .el-dialog__close {
        color: #ffffff;
        font-size: 18px;
        
        &:hover {
          color: rgba(255, 255, 255, 0.8);
        }
      }
    }
  }
  
  .el-dialog__body {
    background: transparent;
    padding: 20px;
    
    .el-form {
      .el-form-item__label {
        color: #ffffff;
        font-weight: 500;
      }
      
      .el-select {
        .el-input__wrapper {
          background: rgba(24, 150, 146, 0.1);
          border: 1px solid rgba(24, 150, 146, 0.4);
          border-radius: 6px;
          
          &:hover {
            border-color: rgba(24, 150, 146, 0.6);
          }
          
          &.is-focus {
            border-color: rgba(24, 150, 146, 0.8);
            box-shadow: 0 0 0 2px rgba(24, 150, 146, 0.2);
          }
          
          .el-input__inner {
            color: #ffffff;
            
            &::placeholder {
              color: rgba(255, 255, 255, 0.6);
            }
          }
          
          .el-input__suffix {
            .el-input__suffix-inner {
              color: #ffffff;
            }
          }
        }
      }
      
      .el-input-number {
        .el-input__wrapper {
          background: rgba(24, 150, 146, 0.1);
          border: 1px solid rgba(24, 150, 146, 0.4);
          border-radius: 6px;
          
          &:hover {
            border-color: rgba(24, 150, 146, 0.6);
          }
          
          &.is-focus {
            border-color: rgba(24, 150, 146, 0.8);
            box-shadow: 0 0 0 2px rgba(24, 150, 146, 0.2);
          }
          
          .el-input__inner {
            color: #ffffff;
            
            &::placeholder {
              color: rgba(255, 255, 255, 0.6);
            }
          }
        }
      }
      
      
    }
  }
  
  .el-dialog__footer {
    background: transparent;
    padding: 16px 20px 20px;
    border-top: 1px solid rgba(24, 150, 146, 0.2);
    
    .dialog-footer {
      display: flex;
      justify-content: flex-end;
      gap: 12px;
      
      .el-button {
        padding: 8px 16px;
        border-radius: 6px;
        font-weight: 500;
        
        &:not(.el-button--primary) {
          background: rgba(255, 255, 255, 0.1);
          border: 1px solid rgba(255, 255, 255, 0.3);
          color: #ffffff;
          
          &:hover {
            background: rgba(255, 255, 255, 0.2);
            border-color: rgba(255, 255, 255, 0.5);
          }
        }
        
        &.el-button--primary {
          background: linear-gradient(135deg, rgba(24, 150, 146, 0.8), rgba(24, 150, 146, 0.6));
          border: 1px solid rgba(24, 150, 146, 0.6);
          color: #ffffff;
          
          &:hover {
            background: linear-gradient(135deg, rgba(24, 150, 146, 1), rgba(24, 150, 146, 0.8));
            border-color: rgba(24, 150, 146, 0.8);
          }
        }
      }
    }
  }
}
</style>